#ifndef DW_MATHS_PLANE_H
#	define DW_MATHS_PLANE_H

#include "maths/vector.h"
#include "maths/point.h"
#include "maths/ray.h"
#include "maths/cuboid.h"

namespace dw {
	namespace maths { 

struct Plane
{

// Fields
public:

	union
	{
		struct
		{
			float a;
			float 											b;
			float 											c;
		};
		struct
		{
			Vector3f normal;
		};
	};
	float d;

// Constructors
public:

																	Plane(const float& a, const float& b, const float& c, const float& d);

																	Plane(const Vector3f& normal = Vector3f(0, 0, 1), const float& d = 0);
																	
																	Plane(const Vector3f& normal, const Point3f& point);
																	
																	Plane(const Point3f& p0, const Point3f& p1, const Point3f& p2);


// Methods
public:

	static Plane transform(const Plane&, const Matrix<float, 4, 4>& m);

	static Plane fromPoints(const Point3f& p0, const Point3f& p1, const Point3f& p2);

	static float distance(const Plane& plane, const Point3f& p);

	static bool intersection(const Plane& plane0, const Plane& plane1, const Plane& plane2, Point3f& intersection);

	/*static bool intersection(const Plane& plane, const Ray& ray, float& t);

	static bool intersection(const Plane& plane, const Cuboid& cuboid);*/

};

	} // namespace maths
} // namespace dw

#endif // !DW_MATHS_PLANE_H
